package com.qfmy.web.app.mapper.listenBook;

import com.qfmy.model.entity.listenBook.PlayRecord;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * @author 清风明月
 * @Package com.qfmy.web.app.mapper.listenBook
 * @date 2025/11/1
 * @description 音频阅读历史
 */
@Mapper
public interface PlayRecordMapper {

    /**
     * 保存播放记录
     * @param playRecord
     */
    void savePlayRecord(PlayRecord playRecord);

    /**
     * 删除播放记录
     * @param playRecordId
     */
    void deletePlayRecord(Integer playRecordId);

    /**
     * 获取播放记录
     * @param userId
     * @return
     */
    List<PlayRecord> getPlayRecord(Long userId);

    /**
     * 根据音频id和用户id获取播放记录
     * @param audioId
     * @param userId
     * @return
     */
    PlayRecord getPlayRecordByAudioId(Integer audioId, Long userId);

    /**
     * 更新播放记录
     * @param playRecord
     */
    void updatePlayRecord(PlayRecord playRecord);

    /**
     * 清空播放记录
     * @param userId
     */
    @Delete("delete from play_record where user_id = #{userId}")
    void clearAllPlayRecord(Long userId);
}
